<h1>
    Welcome!
</h1>

<?php
    $today = date("Y-m-d");
    
    # Hae tänään tehtävät harjoitteet
    $schedule = API::trainingProgramSchedule(array(
        "startdate" => $today,
        "enddate"   => $today
    ));
    
    $list = (array)arrGet($schedule,"list");
    if (!empty($list)) {
        echo "<strong>Today's workouts:</strong><br />";
        
        # Näytä tämän päivän harjoitteet
        $prevId = null;
        foreach ($list as $workout) {
            $tpHashId = htmlescape($workout["hashid"]);
            if ($prevId != $workout["hashid"]) {
                $name = htmlescape($workout["program_name"]);
                
                echo <<<HTML
                    <a
                      class="a-subview-dialog"
                      data-ui-view="tplist"
                      data-ui-subview="info"
                      data-ui-title="$name"
                      data-hashid="$tpHashId"
                      href="#">
                        <strong>$name</strong>
                    </a><br />
HTML;
            }
            
            $hashid = htmlescape($workout["templatehashid"]);
            $extratext = htmlescape($workout["template_extratext"]);
            $workoutDate = htmlescape($today);
            
            echo <<<HTML
<a class="a-subview-dialog margin-left"
  data-ui-view="templatelist"
  data-ui-subview="info"
  data-ui-title="$extratext"
  data-training-program-hashid="$tpHashId"
  data-hashid="$hashid"
  data-workout-date="$workoutDate"
  href="#">
    *&nbsp;$extratext
</a><br />
HTML;

            $prevId = $workout["hashid"];
        }
    }
?>